package cn.xi.dao;

import cn.xi.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;


public interface OrdersettingDao {
    @Insert("insert into t_ordersetting (orderDate,number) values(#{orderDate},#{number})")
    void add(OrderSetting orderSetting);

    @Update("update t_ordersetting set number=#{number} where orderDate=#{date}")
    void update(@Param("date") String date, @Param("number") Integer number);

    @Select("select count(*) from t_ordersetting where orderDate=#{date}")
    int selectid(String date);

    @Select("select * from t_ordersetting where orderDate between #{date1} and #{date2}")
    List<OrderSetting> select(@Param(value = "date1") String date1, @Param(value = "date2") String date2);

    @Select("select COUNT(*) from t_ordersetting where (number>reservations or (reservations is null and number>0) )  and orderDate = #{orderDate}")
    Integer selectnumber(String orderDate);

    @Select("select reservations from t_ordersetting where orderDate=#{orderDate}")
    Integer selectreservations(String orderDate);

    @Insert("update t_ordersetting set reservations=1 where orderDate=#{orderDate}")
    void update_reservations(String orderDate);

    @Insert("update t_ordersetting set reservations=reservations+1 where orderDate=#{orderDate}")
    void updatereservations(String orderDate);
}
